﻿using System;
using System.Collections;
using Huirui.Cavan.Data.Seedwork;
using Huirui.Cavan.Domain.MainBoundedContext.SalesModule;
using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
using NHibernate.Criterion;
using System.Collections.Generic;
using Huirui.Cavan.Core.Extension;

namespace Huirui.Cavan.Infrastructure.Data.MainBoundedContext.SalesModule
{
    #region SalesPrice

    public class SalesPriceRepository : Repository<SalesPrice, SalesPriceSearch>, ISalesPriceRepository
    {
        public override System.Collections.Generic.IList<SalesPrice> GetPageList(SalesPriceSearch search, out long total)
        {
            IList<SalesPrice> result = this.Session.CreateCriteria(typeof(SalesPrice))
                                        .CreateCriteria("Customers")
                                        .Add(Restrictions.Eq("Id", search.CustomerCode))
                                        .List<SalesPrice>();
            total = 0;
            if (result.IsNotNull())
            {
                total = result.Count;
            }

            return result;
        }
    }
    #endregion
}